<%@ page contentType="text/html; charset=UTF-8"%>
<%@page import="com.biz.conf.Global"%>
<%@ include file="/jsp/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jqGird</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <style>
        .ml10 {
            margin-left: 15px;
        }
        .wddd-list-jtzl {
            padding: 10px 0 0 !important;
            text-align: center;
        }.wddd-list-jtzl>ul>li {
             float: left;
             cursor: pointer;
         }
    ul,li{
        list-style-type: none;
    }

    </style>

</head>

<body class="gray-bg" >
<div class="wrapper wrapper-content  animated fadeInRight" id="ccbb">
    <div class="row">
        <div class="col-sm-12">
            <div class="row">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>搜索条件</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content" >
                        <div class="row">
                            <div class="col-md-2"><input placeholder="订单号" id="search_code" class="form-control" ></div>
                            <div class="col-md-2"><input placeholder="开始日期" id="search_startdate" class="form-control layer-date" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" ></div>
                            <div class="col-md-2"><input placeholder="结束日期" id="search_enddate" class="form-control layer-date" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" ></div>
                            <div class="col-md-1"><button id="btn_search" class="btn btn-primary"><i class="fa fa-search"></i>&nbsp;搜索</button></div>
                        </div>
                    </div>
                </div>
            </div>
            <table id="exampleTablePagination"></table>
        </div>
    </div>
</div>

<script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/bootstrap-table.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/locale/bootstrap-table-zh-CN.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/export/bootstrap-table-export.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/editable/bootstrap-table-editable.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/layer/laydate/laydate.js"></script>
<script src="${ctxStatic}/plugins/h+/js/plugins/layer2.4/layer.js"></script>
<script>

</script>
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
<script type="text/javascript">
    //初始化表格对象
    var $table = $('#exampleTablePagination');
    /*
     获取选中行的相关数据
     */
    $(function () {
        $table.on('click-row.bs.table', function (e, row, $element) {
            $('.success').removeClass('success');
            $($element).addClass('success');
        });
        $('#button').click(function () {
            alert('Selected name: ' + getSelectedRow().userName);
        });
    });
    function getSelectedRow() {
        var index = $table.find('tr.success').data('index');
        return $table.bootstrapTable('getData')[index];
    }

    /*
     每一列详情格式化数据
     */
    function formDetail(index, row) {
        return row.detail+index;
    }


    ////////////////////////////////////////////////////////////////////////////////////////以下是通过js方式初始化BootStrapTable/////////////////////////////////////////////

    $table.bootstrapTable({
        url: "${pageContext.request.contextPath}/order/showRefundOrders.ac",
        method: 'post',
        contentType: "application/x-www-form-urlencoded",//必须的
        dataType: "json",
        pageList:[10, 20, 50, 100],//会根据当前的数据量加载合适的pageList
        height: ($(window).height()-100) ,
        //cardView:true,//是否自适应手机
        pagination: true, //分页
        // queryParamsType: "limit",
        singleSelect: false,
        cache:false,
        sortName:"createTime",
        search: false, //显示搜索框
        showColumns:false,
        showRefresh:false,
        showToggle:false,
        showPaginationSwitch:false,
        smartDisplay:true,
        detailView:true,
        toolbar:"#toolbar",
        queryParams: queryParams,//参数
        searchOnEnterKey:true,
        detailFormatter:function(index, record, element){
            var html='</br>';
            html+='<div class=\"wddd-list-jtzl\">'+
            '<ul style="margin-top:10px;"  >'+
            '<li style=\"width:20%\">购买人:</li>'+
            '<li style=\"width:20%\">'+record.buyerName+'</li>'+
            '<li style=\"width:20%\">买家留言:</li>'+
            '<li style=\"width:40%;word-wrap:break-word;\"> <div style="width:400px;word-wrap:break-word;">'+record.message+'</div></li>'+

            '</ul>'+
            '<br class="clear"/>'+

            '<ul style="margin-top:10px;">'+
            '<li style=\"width:20%;line-height:20px;\">商品信息:'+record.goodsName+'<br>'+record.type1Name+record.type2Name+record.type3Name+'</li>';
            if(record.mainType == '3'){
                html+='<li style=\"width:20%;line-height:20px;\"><img src="<%=Global.getConfig("OSSURL_mainType3")%>/';
            }else{
                html+='<li style=\"width:20%;line-height:20px;\"><img src="<%=Global.getConfig("OSSURL")%>/';
            }
            html+= record.goodsPath
            + '" width="100" height="100"></li>'
            + '<li style=\"width:20%;line-height:20px;\">售价:'
            + record.goodPrice
            + '</li>'
            + '<li style=\"width:40%;line-height:20px;\">数量:'
            + record.count
            + '</li>'
            + '</ul>';
            '<br class="clear"/>'+
            + '<ul style="margin-top:10px;">'
            + '<li style=\"width:20% \"></li>'
            + '<li style=\"width:40% \"></li>'
            + '<li style=\"width:20%\"></li>'
            + '<li style=\"width:20%\"></li>' + '</ul>';
            '<br class="clear"/>';
            return html;
        },
        sidePagination: "server", //服务端处理分页
        columns: [

            {field:'mainId', title:'编号', type:'string', align: 'center',visible:false},
            {field:'code', title:'订单编号', type:'string', align: 'center'},
            {field:'paycode',title:'支付单号', type:'string', align: 'center'},
            {field:'goodsName', title:'商品名称', type:'string', align: 'center',formatter:function(value){
                if(value.length>10)
                {
                    return value.substring(0,9)+"...";
                }else{
                    return value;
                }
            }},
         /*   {field:'isGroup', title:'来源', type:'string', align: 'center',formatter:function(value){
                if(value==3)
                {
                    return '<span style="color:green">体验店</span>';
                }else{
                    return '<span style="color:blue">商城</span>';
                }
            }},*/
            {field:'createTime', title:'下单时间', type:'string', align: 'center'},
           /* {field:'alltotal', title:'合计总额', type:'string', align: 'center'},*/
            {field:'payTotal', title:'实付金额', type:'string', align: 'center',formatter:function(value){
                return value+'元';
            }},
            {field:'scoreTotal', title:'实付积分', type:'string', align: 'center',formatter:function(value){
                if(value != undefined)
                {
                    return value+'分';
                }else{
                    return '0分';
                }
            }},
        /*    {field:'coinPayTotal',title:'久零币金额', type:'string', align: 'center',formatter:function(value){
                if(value != undefined)
                {
                    return value;
                }else{
                    return '0';
                }
            }},*/
            {field:'detailState', title:'订单状态', type:'string',align: 'center',formatter:function(value, record, column, grid, dataNo,
                                                                                                                            columnNo){
                if (value==0){
                    return "<font color='red'>待付款</font>";
                } else if(value==1)  {
                    //return "<font color='green'>待发货</font>";
                    return '<button class="btn btn-xs btn-danger" >待发货</button>';
                }else if(value==2){
                    return "待收货";
                }else if(value==3){
                    return "待评价";
                }else if(value==4){
                    return "完成";
                }else if(value==5){
                    return "退款中";
                }else if(value==6){
                    return "已退款";
                }else if(value==7){
                    return "待备货";
                }else{
                    return "备货前退款";
                }
            }},
            {field:'state',title:'退款状态', type:'string',align: 'center',formatter:function(value,record,dataNo){
                if (value==1){
                    return '<button class="btn btn-xs btn-danger"  onclick="showPopup(\''+record.mainId+'\',\''+record.detailId+'\');">待审批</button>';
                } else if(value==2)  {
                    return "<font color='green'>申请通过</font>";
                }else if(value==3)  {
                    return "<font color='green'>申请退回</font>";
                } else if(value==4)  {
                    return "<font color='green'>退款成功</font>";
                }else if(value==5)  {
                    return "<font id='refundFail"+dataNo+"'data-title='失败原因' data-placement='left' data-content='"+record.remarks+"' color='red' >退款失败</font>";
                }
            }}
        ]
    });

    /*
     搜索按钮
     */
    $("#btn_search").click(function(){
        $table.bootstrapTable('selectPage', 1);
        $table.bootstrapTable('refresh', queryParams);
    });

    function reloadTable(){
        $table.bootstrapTable('selectPage', 1);
        $table.bootstrapTable('refresh', queryParams);
    }

    /*
     传递的参数
     */
    function queryParams(params) {
        var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            limit: params.limit,  //页面大小
            offset: params.offset, //页码
            pageindex:params.pageNumber,
            code: $("#search_code").val(),
            startDate: $("#search_startdate").val(),
            endDate: $("#search_enddate").val()
        };
        return temp;
    }
    ///////////////////////////////////////////////////////////////toolbar///////////////////////////////////////

    // 打开订单详情
    function openDetail(id,detailId) {
        window.location.href = "${pageContext.request.contextPath}/order/toRefundDetail.ac?id="
                + id+"&detailId="+detailId+'&type=od';
    }



    function showPopup(id,detailId){
        //自定页
        layer.open({
            type: 2,
            shift:2,//动画类型
            moveType:1,
            maxmin: true,
            shadeClose: true, //开启遮罩关闭
            title:'<span style="font-weight:600;font-size: 13px;color:#676a6c;">审批</span>',
            area: ['700px', '450px'],
            content: '${pageContext.request.contextPath}/order/toRefundDetail.ac?id='
            + id+'&detailId='+detailId+'&type=sp',
            success: function(layero, index){

            },
            cancel: function(index){
                $table.bootstrapTable('refresh', queryParams);
                return true;
            },
            close  : function(index){
                $table.bootstrapTable('refresh', queryParams);
            },
            end : function(index){
                $table.bootstrapTable('refresh', queryParams);
            }
        });
    }


</script>
</body>


</html>
